local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
local theme = require("theme")
local dpi	= require("beautiful.xresources").apply_dpi




local layoutbox = {}




function layoutbox:setup(s)
	self.widget = wibox.widget{
		{
			{
				{
					{
						awful.widget.layoutbox(s),
						id      = "margin",
						widget	= wibox.container.margin
					},
					forced_height = dpi(16),
					forced_width = dpi(16),
					valign = "center",
					halign = "center",
					widget	= wibox.container.place,
				},
				left   = dpi(10),
				right  = dpi(10),
				widget	= wibox.container.margin,
			},
			id = "background",
			bg = "",
			--fg = theme.widget_fg,
			--bg = theme.widget_bg,
			--shape = function(cr, width, height)
			--	gears.shape.rounded_rect(cr, width, height, theme.widget_radius)
			--end,
			widget = wibox.container.background,
		},
		margins = theme.widget_margins,
		widget	= wibox.container.margin,
		set_bg = function(self, var)
			self:get_children_by_id("background")[1].bg = var
		end,
		set_fg = function(self, var)
			self:get_children_by_id("background")[1].fg = var
		end
	}

	--self.widget:connect_signal('mouse::enter',function() 
	--	self.widget.bg = theme.widget_bg_hover
	--end)
	--self.widget:connect_signal('mouse::leave',function() 
	--	self.widget.bg = theme.widget_bg
	--end)

	self.widget:buttons(gears.table.join(
		awful.button({ }, 1, function () awful.layout.inc( 1) end),
		awful.button({ }, 2, function () awful.layout.set(awful.layout.suit.floating) end),
		awful.button({ }, 3, function () awful.layout.inc(-1) end),
		awful.button({ }, 4, function () awful.layout.inc( 1) end),
		awful.button({ }, 5, function () awful.layout.inc(-1) end)
	))

	return self.widget
end




return layoutbox
